package ACWing.TheNnderlyingAlgorithm.双指针;
//800. 数组元素的目标和

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/25 22:02
 */
public class ArrayElementsOFTheTargetAnd {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int x=sc.nextInt();
        int[]arr=new int[n];
        int[]arr2=new int[m];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            arr2[i]=sc.nextInt();
        }
        //本题特征上升序列所有i不满足的数i+1肯定也不满足所以j从后往前进
        int j=m-1;
        for (int i = 0; i < n; i++) {
            while (j>=0){
                if(x-arr[i]<arr2[j]){
                    j--;
                }else {
                    break;
                }
            }
            if(x==arr[i]+arr2[j]){
                System.out.println(i);
                System.out.println(j);
                return;
            }
        }
    }
}
